import java.util.Scanner;
import java.util.*;
public class MC0336灵异空间 {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        // code here
        int n = input.nextInt();
        int m = input.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++){
            arr[i] = input.nextInt();
        }
        while (m-->0){
            int L = input.nextInt();
            int R = input.nextInt();
            while( L < R){
                int t = arr[L-1];
                arr[L-1] = arr[R-1];
                arr[R-1] = t;
                L++;
                R--;
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i : arr) {
            sb.append(i).append(" ");
        }
        System.out.println(sb.toString());
        input.close();
    }
}
